﻿using System;

namespace FDEE.Model
{


    public class MARebarRecord : RebarBase
    {
        public int LapLengthTop, LapLengthBot, Phi, hook;
        public double DowelLen;
        /// <summary>
        /// MA 型钢筋长度重量计算 - 直筋，可能存在两端搭接和锚固承台（其他构件）
        /// </summary>
        /// <param name="mBarMark">钢筋主编号，例如1</param>
        /// <param name="sBarMark">钢筋次编号，例如1.1，默认为0</param>
        /// <param name="cBarMark">钢筋字符编号，例如1a，默认为空</param>
        /// <param name="diameter">钢筋直径，按eDB选取</param>
        /// <param name="len"></param>
        /// <param name="lapLengthTop"></param>
        /// <param name="lapLengthBot"></param>
        /// <param name="phi"></param>
        /// <param name="dowellen"></param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MARebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            int len, int lapLengthTop, int lapLengthBot, double dowellen,
            int quantity, eShapeType shapeConfig) : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig)
        {
            DowelLen = dowellen; //主筋接入承台内长度
            LapLengthTop = lapLengthTop; //顶部搭接长
            LapLengthBot = lapLengthBot; //底部搭接长
            A = len;
            this.Formula = "";
        }
        /// <summary>
        /// MA类型钢筋长度计算，L=A，无弯钩等
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MARebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double len, int quantity, eShapeType shapeConfig,EXNumber ex=null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig,ex)
        {
            A = len;
            d = ((int)diameter);
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            this.Formula = "L=A";
        }



        public override void SetLength()
        {
            Length = Math.Round(A * 0.001,3, MidpointRounding.AwayFromZero);
        }
    }
    public class MABRebarRecord : RebarBase
    {
        /// <summary>
        /// MA直线包含搭接类型钢筋长度计算，L=A+B，
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MABRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double a, double b, int quantity, eShapeType shapeConfig, EXNumber ex = null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig, ex)
        {
            A = a;
            B = b;
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            d = ((int)diameter);
            this.Formula = "L=A+B";
        }

        //public MABRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
        //  int a, int b, int quantity, eShapeType shapeConfig)
        //  : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig)
        //{
        //    A = a;
        //    B = b;
        //    d = ((int)diameter);
        //    this.Formula = "L=A+B";
        //}
        public override void SetLength()
        {
            Length = Math.Round((A + B) * 0.001, 3, MidpointRounding.AwayFromZero);
            //Length = (A + EXNumberList.exNumber["A"] * 0.5 + B + EXNumberList.exNumber["B"] * 0.5) * 0.001;
        }
    }

    public class MABCRebarRecord : RebarBase
    {
        /// <summary>
        /// MA直线包含搭接类型钢筋长度计算，L=A+B，
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MABCRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double a, double b, double c, int quantity, eShapeType shapeConfig, EXNumber ex = null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig,ex)
        {
            A = a;
            B = b;
            C = c;
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            d = ((int)diameter);
            this.Formula = "L=A+B+C";
            if (Length > 12 || Length < 0)
            {
                throw new Exception("三段直线长度计算异常，请查找原因！");
            }
        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("三段直线长度计算异常，请查找原因！");
            }
        }
    }

    public class M2ABCDRebarRecord : RebarBase
    {
        /// <summary>
        /// MA直线包含搭接类型钢筋长度计算，L=A+B，
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public M2ABCDRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double a, double b, double c, double d, int quantity, eShapeType shapeConfig, EXNumber ex = null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig, ex)
        {
            A = a;
            B = b;
            C = c;
            D = d;
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            d = ((int)diameter);
            this.Formula = "L=2A+B+C+D";
            if (Length > 12 || Length < 0)
            {
                throw new Exception("三段直线长度计算异常，请查找原因！");
            }
        }

        public override void SetLength()
        {
            Length = Math.Round((A*2 + B + C+D) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("三段直线长度计算异常，请查找原因！");
            }
        }
    }

    public class MARRebarRecord : RebarBase
    {       
        /// <summary>
        /// MA类型钢筋长度计算，L=A，无弯钩等
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MARRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double len, double Radia, int quantity, eShapeType shapeConfig,EXNumber ex=null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig,ex)
        {
            A = len;
            d = ((int)diameter);
            R = Radia;
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            this.Formula = "L=A";
        }



        public override void SetLength()
        {
            Length = Math.Round(A * 0.001,3, MidpointRounding.AwayFromZero);
        }
    }
    public class MABRRebarRecord : RebarBase
    {
        /// <summary>
        /// MA直线包含搭接类型钢筋长度计算，L=A+B，
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MABRRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double a, double b, double Radia, int quantity, eShapeType shapeConfig, EXNumber ex = null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig, ex)
        {
            A = a;
            B = b;
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            R = Radia;
            d = ((int)diameter);
            this.Formula = "L=A+B";
        }
      
        public override void SetLength()
        {
            Length = Math.Round((A + B) * 0.001, 3, MidpointRounding.AwayFromZero);
        }
    }

    public class MABCRRebarRecord : RebarBase
    {
        /// <summary>
        /// MA直线包含搭接类型钢筋长度计算，L=A+B，
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MABCRRebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double a, double b, double c, double Radia, int quantity, eShapeType shapeConfig,EXNumber ex=null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig,ex)
        {
            A = a;
            B = b;
            C = c;
            d = ((int)diameter);
            R = Radia;
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            this.Formula = "L=A+B+C";
            if (Length > 12 || Length < 0)
            {
                throw new Exception("三段直线长度计算异常，请查找原因！");
            }
        }

        public override void SetLength()
        {
            Length = Math.Round((A + B + C) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("三段直线长度计算异常，请查找原因！");
            }
        }
    }

    public class MAURebarRecord : RebarBase
    {
        /// <summary>
        /// MA直线包含搭接类型钢筋长度计算，L=A+B，
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="len">A，见示例图</param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        public MAURebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            double a, double b, double c, int quantity, eShapeType shapeConfig, EXNumber ex = null)
            : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig, ex)
        {
            A = a;
            B = b;
            C = c;
            d = ((int)diameter);
            if (ex != null)
            {
                EXNumberList = ex;
            }
            else
            {
                EXNumberList = new EXNumber();
            }
            this.Formula = "L=2A+2B+C";
            if (Length > 12 || Length < 0)
            {
                throw new Exception("对称弯曲直线长度计算异常，请查找原因！");
            }
        }

        public override void SetLength()
        {
            Length = Math.Round((A*2 + B*2 + C) * 0.001, 3, MidpointRounding.AwayFromZero);
            if (Length > 12 || Length < 0)
            {
                throw new Exception("对称弯曲直线长度计算异常，请查找原因！");
            }
        }
    }
}
